package other;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

// 节点向前向后(通过改变在布局的节点数组的位置)
public class toFrontOrBackDemo extends Application {
	private Pane root = new Pane();
	private ImageView iv1;
	private ImageView iv2;
	
	public static void main(String[] args) {
		launch(args);
	}
	
	@Override
	public void start(Stage stage) {
		
		iv1 = new ImageView("image/1.jpg");
		iv1.setFitWidth(200);
		iv1.setFitHeight(200);
		iv1.setTranslateX(150);
		
		iv2 = new ImageView("image/2.jpg");
		iv2.setFitWidth(200);
		iv2.setFitHeight(200);
		root.getChildren().addAll(iv1, iv2);
		
		Scene scene = new Scene(root, 500, 400);
		stage.setScene(scene);
		stage.show();
		
		// 事件
		iv1.setOnMouseClicked(e -> {
			iv1.toFront();
		});
		
		iv2.setOnMouseClicked(e -> {
			iv2.toFront();
		});
	}
}
